using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class RD_RelationsMap : EntityTypeConfiguration<RD_Relations>
    {
        public RD_RelationsMap()
        {
            // Primary Key
            this.HasKey(t => new { t.Object, t.Published, t.Child, t.table, t.KEYName_, t.Reference, t.KeyType, t.ReferenceType, t.order });

            // Properties
            this.Property(t => t.Object)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.Published)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.Child)
                .IsRequired()
                .HasMaxLength(9);

            this.Property(t => t.table)
                .IsRequired()
                .HasMaxLength(17);

            this.Property(t => t.KEYName_)
                .IsRequired()
                .HasMaxLength(7);

            this.Property(t => t.Reference)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.KeyType)
                .IsRequired()
                .HasMaxLength(1);

            this.Property(t => t.ReferenceType)
                .IsRequired()
                .HasMaxLength(1);

            this.Property(t => t.order)
                .IsRequired()
                .HasMaxLength(1);

            // Table & Column Mappings
            this.ToTable("RD_Relations");
            this.Property(t => t.Object).HasColumnName("Object");
            this.Property(t => t.Published).HasColumnName("Published");
            this.Property(t => t.Child).HasColumnName("Child");
            this.Property(t => t.table).HasColumnName("table");
            this.Property(t => t.KEYName_).HasColumnName("KEYName	");
            this.Property(t => t.Reference).HasColumnName("Reference");
            this.Property(t => t.KeyType).HasColumnName("KeyType");
            this.Property(t => t.ReferenceType).HasColumnName("ReferenceType");
            this.Property(t => t.order).HasColumnName("order");
        }
    }
}
